package testing;

import processing.core.*;
import processing.xml.*;

import java.applet.*;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;
import java.awt.event.FocusEvent;
import java.awt.Image;
import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
import java.util.zip.*;
import java.util.regex.*;

public class readFileTest extends PApplet {

	/**
	 * LoadFile 1
	 * 
	 * Loads a text file that contains two numbers separated by a tab ('\t'). A
	 * new pair of numbers is loaded each frame and used to draw a point on the
	 * screen.
	 */

	String[] lines;
	int index = 0;

	public void setup() {
	
	}
	


	public void draw() {
		size(200, 200);
		background(0);
		stroke(255);
		frameRate(12);
		lines = loadStrings("../resource/consumption.txt");
		
		//////////
		if (index < lines.length) {
			String[] pieces = split(lines[index], '\t');
			if (pieces.length == 2) {
			//	int x = PApplet.parseInt(pieces[0]) * 2;
				String s = pieces[0];
				int y = PApplet.parseInt(pieces[1]);
		//		point(x, y);
				
				System.out.println("this line is:"+s+" the number is:"+y);
			}
			// Go to the next line for the next run through draw()
			index = index + 1;
		}
	}
	
	

}
